<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" size="medium" class="ry_form">
    
      <el-form-item label="演员名称" prop="actorName">
        <el-input
          v-model="queryParams.actorName"
          placeholder="请输入演员名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     
      <el-form-item class="flex_one tr">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"

        >新增</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="actorMangeList" >
      <!-- <el-table-column label="演员头像" align="center" prop="pic">
        <template slot-scope="{ row }">
          <el-image v-if="row.headImgurl" :src="row.headImgurl" :preview-src-list="[row.headImgurl]" class="small-img circle-img"/>
        </template>
      </el-table-column> -->
      <el-table-column label="演员名称" min-width="200" align="center" prop="outProductId">
        <template slot-scope="{ row }">
          <div>{{row.name}}</div>
          
        </template>
      </el-table-column>
     
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
  <script>
  import {listactor,delactor} from "@/api/actor/actorMage";
export default {
  dicts: [],
  data() {
    return {
          // 显示搜索条件
      showSearch: true,
      open: false,
      loading: false,
      actorMangeList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        actorName:''
      },
      total: 0,
    };
  },
  created() {
    this.getList();
  },
  methods: {
     /** 重置按钮操作 */
     resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    getList() {
        this.loading = true;
      const {pageNum, pageSize} = this.queryParams;
      const query = {...this.queryParams, pageNum: undefined, pageSize: undefined};
      const pageReq = {page: pageNum - 1, size: pageSize};
      listactor(query, pageReq).then(response => {
        const { content, totalElements } = response
        this.actorMangeList = content;
        this.total = totalElements;
        this.loading = false;
      });
    },
     /** 新增按钮操作 */
     handleAdd() {
     this.$router.push({ path: '/actorManagement/edit' });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
     this.$router.push({ path: '/actorManagement/edit', query: { id: row.id } });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除演员信息编号为"' + ids + '"的数据项？').then(function() {
        return delactor(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
  },
};
</script>
  